package priv.pront.code.robot.roboCom_na_2021;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-08-15 15:44
 */
public class Main {

    static int N, M;
    static int[][] toys;
    static int[] states;
    static boolean[] used;
    static List<Integer> serials, ans;

    public static void main(String[] args) throws IOException {
        N = Reader.nextInt();
        M = Reader.nextInt();
        states = new int[N];
        toys = new int[M][N];
        used = new boolean[M];
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                toys[i][j] = Reader.nextInt();
            }
        }
        Arrays.fill(states, -1);
        serials = new ArrayList<>();
        for (int i = 0; i < M; i++) dfs(i);
        StringBuilder sb = new StringBuilder();
        for (int i : ans) sb.append(' ').append(i + 1);
        System.out.println(sb.substring(1));
    }

    static void dfs(int toy) {
        if (ans != null && serials.size() == ans.size()) return;
        int[] backtrace = new int[N];
        System.arraycopy(states, 0, backtrace, 0, N);
        update(toy);
        serials.add(toy);
        used[toy] = true;
        if (check()) {
            if (ans == null || serials.size() < ans.size()) {
                ans = new ArrayList<>(serials);
            }
        }
        for (int i = 0; i < M; i++) {
            if (!used[i]) dfs(i);
        }
        used[toy] = false;
        System.arraycopy(backtrace, 0, states, 0, N);
        serials.remove(serials.size() - 1);
    }

    static boolean check() {
        for (int state : states) {
            if (state != 1) return false;
        }
        return true;
    }

    static void update(int idx) {
        for (int i = 0; i < N; i++) {
            int state = toys[idx][i];
            if (state == 0) continue;
            states[i] = state;
        }
    }

    static class Reader {
        static final BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
        static final StreamTokenizer ST = new StreamTokenizer(BR);

        static String next() throws IOException {
            ST.nextToken();
            return ST.sval;
        }

        static double nextDouble() throws IOException {
            ST.nextToken();
            return ST.nval;
        }

        static int nextInt() throws IOException {
            return (int) nextDouble();
        }
    }
}
